package com.example.zidinyi;

import java.io.Serializable;

/**
 * @author binxie
 * @date 2015/9/11
 * @see 保存单个音乐信息
 */
public class MusicInfoData implements Serializable, Cloneable {
    private String name;                // 歌曲名
    private String path;                // 存放路径
    private int id;                    // id  (获取list位置的重要参数)
    private String artist;                // 歌手
    private String album;                // 专辑
    private String totalTime;            // 歌曲总时间
    private String pinyin;                // 拼音
    private char initial;                // 首字母
    private boolean isCollect = false;
    private int type;                    // MP3或CD

    /**
     * 保存从音频文件中解析出来的图片字节数组
     */
    private byte[] bytes;

    /**
     * cursor 中获取专辑id用于确定图片
     */
    private int album_id;

    private String dirPath;
    /**
     * cursor 中获取的音乐ID
     */
    private int _id;

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    //-1 未查询 0 没有图片 1 有图片
    private int has_bitmap = -1;

    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public int getAlbum_id() {
        return album_id;
    }

    public void setAlbum_id(int album_id) {
        this.album_id = album_id;
    }

    public int getHas_bitmap() {
        return has_bitmap;
    }

    public void setHas_bitmap(int has_bitmap) {
        this.has_bitmap = has_bitmap;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        String musictype = path.substring(path.lastIndexOf("."), path.length());
        String musictypelowercase = musictype.toLowerCase();
        String newpath = path.replace(musictype, musictypelowercase);
        this.path = path;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }

    public String getAlbum() {
        return album;
    }

    public void setAlbum(String album) {
        this.album = album;
    }

    public String getTotalTime() {
        return totalTime;
    }

    public void setTotalTime(String totalTime) {
        this.totalTime = totalTime;
    }

    public boolean isCollect() {
        return isCollect;
    }

    public void setCollect(boolean isCollect) {
        this.isCollect = isCollect;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getPinyin() {
        return pinyin;
    }

    public void setPinyin(String pinyin) {
        this.pinyin = pinyin;
    }

    public char getInitial() {
        return initial;
    }

    public void setInitial(char initial) {
        this.initial = initial;
    }

    public String getDirPath() {
        return dirPath;
    }

    public void setDirPath(String dirPath) {
        this.dirPath = dirPath;
    }


    @Override
    public String toString() {
        return "MusicInfoData [name=" + name + ", path=" + path + ", id=" + id + ", artist=" + artist + ", album="
                + album + ", totalTime=" + totalTime + ", pinyin=" + pinyin + ", initial=" + initial + ", isCollect="
                + isCollect + ", type=" + type + ", dirPath=" + dirPath + "]";
    }

    @Override
    public boolean equals(Object o) {
        // TODO Auto-generated method stub

        if (o instanceof MusicInfoData) {
            MusicInfoData question = (MusicInfoData) o;
            boolean ideq = true;

            ideq = this.id == question.id;

            return ideq;
        }

        return super.equals(o);
    }

    @Override
    public MusicInfoData clone() {
        MusicInfoData data = null;
        try {
            data = (MusicInfoData) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return data;
    }
}
